/*********************************************************/
/*    Konami PCM controller                              */
/*********************************************************/

#pragma once

#ifndef __K007232_H__
#define __K007232_H__

#define  KDAC_A_PCM_MAX    (2)		/* Channels per chip */

class CK007232 : public CBaseSoundDevice {
	private:
			UINT8			vol[KDAC_A_PCM_MAX][2];	/* volume for the left and right channel */
			UINT32			addr[KDAC_A_PCM_MAX];
			UINT32			start[KDAC_A_PCM_MAX];
			UINT32			step[KDAC_A_PCM_MAX];
			UINT32			bank[KDAC_A_PCM_MAX];
			int				play[KDAC_A_PCM_MAX];

			UINT8 			wreg[0x10];	/* write data */
			UINT8 *			pcmbuf[2];	/* Channel A & B pointers */

			UINT32  		clock;          /* chip clock */
			UINT32  		pcmlimit;

			//sound_stream * 	stream;
			//const k007232_interface *intf;
			UINT32 			fncode[0x200];

			CAudioBuffer* lbuf;
			CAudioBuffer* rbuf;

			int locked; // Set to 1 if we don't have ROMs

	public:
		void SetRom(int slot, CMemory* rom);
		void WriteReg(UINT8 reg, UINT8 data);
		int Buffer(short** buf, int length);
		void Write(UINT64 offset, UINT8 data);
		UINT8 Read(UINT64 offset);
		void Init(CMixer* mix, unsigned int clock);
		void Reset();
		void Shutdown();


};

// MAME-specific crap
/*
typedef struct _k007232_interface k007232_interface;
struct _k007232_interface
{
	void (*portwritehandler)(const device_config *, int);
};

WRITE8_DEVICE_HANDLER( k007232_w );
READ8_DEVICE_HANDLER( k007232_r );

void k007232_set_bank( const device_config *device, int chABank, int chBBank );

//
// The 007232 has two channels and produces two outputs. The volume control
// is external, however to make it easier to use we handle that inside the
// emulation. You can control volume and panning: for each of the two channels
// you can set the volume of the two outputs. If panning is not required,
// then volumeB will be 0 for channel 0, and volumeA will be 0 for channel 1.
// Volume is in the range 0-255.
//
// SMSE2K does this through the mixer rather than on the chip.
void k007232_set_volume(const device_config *device,int channel,int volumeA,int volumeB);

DEVICE_GET_INFO( k007232 );
#define SOUND_K007232 DEVICE_GET_INFO_NAME( k007232 )
*/
#endif /* __K007232_H__ */
